var layer;
var $;
var element;
var form;
var table;
layui.use(['element','layer','form','table'], function(){
    layer = layui.layer;
    $ = layui.jquery;
    element = layui.element;
    form = layui.form;
    table = layui.table;
    load();
    table.on("row(tableDemo)",function(obj){
        $("input[name=deptName]").val(obj.data.menuName);
        $("input[name=deptId]").val(obj.data.id);
    })
})
function load(){
    $.ajax({
        type:"get",
        url:"/personnel/selDeptName",
        async:true,
        data:{},
        success:function(res){
            getTable(res.data.children);
        }
    });
}
/**
 * table
 * */
function getTable(data){
    table.render({
        elem:"#tableDemo",//容器
        title:"部门数据列表",
        limit:4,//分页显示条数
        width:550,
        page:true,
        data:data,
        cols:[[//定义列
            {type:'radio',align:'center',width:50},//复选框靠左
            {title:'序号',align:'center',width:60,templet:function(data){
                    return data.LAY_INDEX;
                }},
            {field:"id",title:"部门编号",align:'center',width:167},
            {field:"menuName",title:"部门名称",align:'center',width:268}
        ]]
    });
}
/**
 *  获取部门
 * */
function updDeptInfo(){
    var deptName = $("input[name=deptName]").val();
    var deptId = $("input[name=deptId]").val();
    window.parent.$("input[name=deptName]").val(deptName);
    window.parent.$("input[name=deptId]").val(deptId);
    var layer=parent.layer;
    window.parent.layer.close(layer.index);
}
/**
 *  点击 取消关闭弹出层
 */
function closeLayer(){
    var layer=parent.layer;
    layer.close(layer.index);
}